<template>
  <a-pagination
    :total="total"
    v-model="currentPage"
    show-total
    size="small"
    show-jumper
    @change="handleCurrentChange"
    @page-size-change="handleSizeChange"
    show-page-size
  />
</template>


<script>
import { defineComponent } from 'vue';
import { computed } from 'vue';

export default defineComponent({
  props: {
    total: {
      require: true,
      default: 88,
    },
    page: {
      require: true,
      default: 1,
    },
    limit: {
      require: true,
      default: 10,
    },
    pageSize: {
     type: Array,
     default() {
       return [10, 20, 30, 40]
     },
    },
  },
  setup(props, { emit }) {
    const currentPage = computed({
      get() {
        return props.page;
      },
      set(val) {
        emit('update:page', val);
      },
    });
    const pageSize = computed({
      get() {
        return props.limit;
      },
      set(val) {
        emit('update:limit', val);
      },
    });
    const handleSizeChange = (val) => {
      emit('pagination', { page: currentPage.value, limit: val });
    };
    const handleCurrentChange = (val) => {
      emit('pagination', { page: val, limit: pageSize.value });
    };
    return {
      currentPage,
      pageSize,
      handleSizeChange,
      handleCurrentChange,
    };
  },
});
</script>

